﻿using System.Windows.Forms;
using ClientApp.Forms;
using GianosNET.Common.Classes;

namespace ClientApp.UC
{
    public partial class ucLoopingStatus : UserControl
    {
        #region Eventi

        public event CommonHandlers.LoopingPauseChanged LoopingPauseChanged;
        public event CommonHandlers.LoopingForceStart LoopingForceStart;

        #endregion



        public ServiceInfo Info { get; set; }
        public bool Idle { get; set; }
        public ucLoopingStatus()
        {
            InitializeComponent();
            Idle = false;
        }

        public new string Text
        {
            get { return lblLoopingStatus.Text; }
            set{ lblLoopingStatus.Text = value; }
        }

        private void ctx_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            TSMIForceLoopRestart.Enabled = Idle;
        }

        private void TSMIForceLoopRestart_Click(object sender, System.EventArgs e)
        {
            if (Idle && LoopingForceStart != null)
                LoopingForceStart(Info.SvcId);
        }

        private void TSMIEditPausaTime_Click(object sender, System.EventArgs e)
        {
            using (frmAskPauseTime frm = new frmAskPauseTime(Info.SvcId, Info.LoopingPause))
                if (frm.ShowDialog() == DialogResult.OK)
                    if (LoopingPauseChanged != null)
                        LoopingPauseChanged(Info.SvcId, frm.LoopingPause);
        }
    }
}
